// all_test02.cpp : Defines the entry point for the application.
//

#include <stdio.h>

#include "TankFactory.h"
#include "Tank.h"
#include "Graphics.h"

#define kHalfQuarter 0.785

#define kChangePoint 8 * kHalfQuarter

int main(int argc, char **argv)
{
    Graphics::getGraphics().initialize();
    // ==========================
    _Tank tank( TankFactory::BuildBase1Tank() );

    BaseComponent::point centerPoint = {400, 300};

    tank->MoveTo( centerPoint );
    tank->RotateTo( 0 );
    float rotationStep = .017;

    for ( float i = .0, j = .0; i < 7.0; i += rotationStep, j += rotationStep ) {
        al_clear_to_color(al_map_rgb(0,0,0));
        tank->Move( 2.5 );
        tank->Rotate( rotationStep );
//		tank->RotateTo( i );
		tank->RotateTurretTo( 0, j );
		Graphics::getGraphics().drawCenterLines();
        tank->Draw();

        Graphics::getGraphics().step();

        if ( i >= kChangePoint || i <= -kChangePoint ) {
            rotationStep = -rotationStep;
        }
    }


    // ==========================

    Graphics::getGraphics().step( 2 );

    Graphics::getGraphics().finalize();

    return 0;
}